<template>
  <div class="app-container">
      角色权限列表
      <el-form :inline="true" class="demo-form-inline">
         <el-form-item>
            <el-input  v-model="searchObj.username" placeholder="用户名"/>
         </el-form-item>
         <el-form-item>
            <el-input v-model="searchObj.roles" placeholder="角色名"/>
         </el-form-item>
         <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      </el-form>
      <el-table
      :data="list" stripe style="width: 100%" >
         <el-table-column type="index" width="50" label="序号"/>
         <el-table-column prop="userName" label="用户"/>
         <el-table-column prop="roleName" label="角色"/>
         <el-table-column prop="permName" label="api名称" />
         <el-table-column prop="permTag" label="api标签"/>
         <el-table-column prop="url" label="api基本路径"/>
        <el-table-column prop="description" label="角色描述"/>

         <el-table-column label="操作" width="120" align="center">
            <template slot-scope="scope">
               <el-button type="danger" size="mini"
                  icon="el-icon-delete" @click="removeDataById(scope.row.permId)">删除</el-button>
            </template>
         </el-table-column>

      </el-table>
      <!-- 分页 -->
      <el-pagination
      :current-page="current"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getList"/>

   </div>
</template>
<script>
//引入接口定义的js文件
import hospset from '@/api/hospset'
import {getPermission} from "@/views/api/myselfManager";

export default {
   //定义变量和初始值
   data() {
      return {
         current:1, //当前页
         limit:5, //每页显示记录数
         searchObj:{}, //条件封装对象
         list:[], //每页数据集合
         total:0, //总记录数
      }
   },
   created() { //在页面渲染之前执行
      //一般调用methods定义的方法，得到数据
      this.getList()
   },
   methods: {//定义方法，进行请求接口调用

      //权限列表
      getList(page=1) { //添加当前页参数
         this.current = page
         // hospset.getHospSetList(this.current,this.limit,this.searchObj)
         //    .then(response => { //请求成功response是接口返回数据
         //       //返回集合赋值list
         //       this.list = response.data.records
         //       //总记录数
         //       this.total = response.data.total
         //    })
         //    .catch(error => {//请求失败
         //       console.log(error)
         //    })
        let data={
          current:this.current,
          limit:this.limit,
          searchObj:this.searchObj
        }

        console.log(data)
        getPermission(data).then(res=>{


          console.log(res.data)

          this.list=res.data.data.list;
                this.total = res.data.data.total


        }).catch()

      },
   }
}
</script>
